﻿Public Class MainForm

    Private _idEtairias As String
    Public Property idEtairias() As String
        Get
            Return _idEtairias
        End Get
        Set(ByVal value As String)
            _idEtairias = value
        End Set
    End Property

    Public Sub New(ByVal id)
        InitializeComponent()
        Me.idEtairias = id
    End Sub

    Private Sub Information_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Information.Click
        AboutBoxInformation.ShowDialog()
    End Sub

    Private Sub Printers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Printers.Click
        PrintOptionsDialog.ShowDialog()
    End Sub

    Private Sub EndApplication_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EndApplication.Click
        Me.Close()
    End Sub

    Private Sub ΑριθμομηχανήToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ΑριθμομηχανήToolStripMenuItem.Click
        Dim calc_p As New System.Diagnostics.Process
        calc_p.StartInfo.FileName = "Calc.exe"
        calc_p.Start()
    End Sub

    Private Sub ΣημειωματάριοToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ΣημειωματάριοToolStripMenuItem.Click
        Dim note_p As New System.Diagnostics.Process
        note_p.StartInfo.FileName = "Notepad.exe"
        note_p.Start()
    End Sub

    Private Sub ΕπιχείρισηToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ΕπιχείρισηToolStripMenuItem.Click
        Dim Epixirisi As New Epixirisi(False)
        Epixirisi.gemisma(idEtairias)
        newTab(Epixirisi)
    End Sub

    Private Sub ΠελάτεςToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ΠελάτεςToolStripMenuItem.Click
        Pelates.gemisma(idEtairias)
        newTab(Pelates)
    End Sub


    Private Sub ΠρομηθευτέςToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ΠρομηθευτέςToolStripMenuItem.Click
        Promitheutes.gemisma(idEtairias)
        newTab(Promitheutes)
    End Sub

    Private Sub ΠροιόνταToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ΠροιόνταToolStripMenuItem.Click
        Proionta.gemisma(idEtairias)
        newTab(Proionta)
    End Sub

    Private Sub ΑγορέςToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ΑγορέςToolStripMenuItem.Click
        newTab(Agores)
    End Sub

    Private Sub ΠωλήσειςToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ΠωλήσειςToolStripMenuItem.Click
        newTab(Poliseis)
    End Sub

    'Inserts the requsted form in a new tabpage or activates an existing form in the control
    Private Sub newTab(ByVal formTab As Form)
        If formTab.Tag Is Nothing Then
            formTab.Tag = mainTabControl.TabPages.Add(formTab)
        Else
            mainTabControl.TabPages(formTab).Select()
        End If

    End Sub

    'Tab draw style
    Private Sub mainTabControl_GetTabRegion(ByVal sender As Object, ByVal e As MdiTabControl.TabControl.GetTabRegionEventArgs) Handles mainTabControl.GetTabRegion
        Dim x As New Drawing2D.GraphicsPath
        x.AddArc(New Rectangle(0, 0, e.TabWidth, e.TabHeight * 2 / 3), 0, -180)
        x.Flatten()
        Array.Resize(e.Points, x.PointCount)
        For i As Integer = 0 To x.PointCount - 1
            e.Points(i) = New Point(x.PathPoints(i).X, x.PathPoints(i).Y)
        Next
    End Sub

End Class

